<% project_id = session[:selected_project].to_i %>

<!-- Tasks  -->
<!--<img src="/images/tasks.png" align="left">-->
<h2>Tasks</h2>

<%= link_to_function("Filters and Actions","$('filters').toggle();") %>

<div id="filters" class="block_menu" style="display:none;">
<b>Filters:</b>
Project: 
<select id="project_selection" onchange="select_project(this.value)">
<option value="0">All</option>
<% @projects.each {|p| -%>
<option value="<%=p.id%>"<%if session[:selected_project].to_i==p.id then%> selected<%end%>><%= p.name %></option>
<%   } -%>
</select>
Resp: 
<select name="" onchange="select_resp(this.value)">
<option value="0">All</option>
<% @resp.each {|u| -%>
<option id="resp<%=u.id%>" value="<%=u.id%>"<%if session[:selected_resp].to_i==u.id then%> selected<%end%>><%= u.name %></option>
<% } -%>
</select>

State: 
<select id="state_combo" onchange="select_state(this.value)">
<option value="0">All (<%=@state_count['all']%>)</option>
<%
 [['Inbox','inbox'],
 ['Next Action','next'],
 ['Waiting','waiting'],
 ['Sometime/Maybe','maybe'],
 ['Reference','ref']].each {|text,state| -%>
<option id="state<%=state%>" value="<%=state%>"<%if session[:selected_state]==state then%> selected<%end%>><%= text %> (<%=@state_count[state]%>)</option>
<% } -%>
</select>

Special:
<select id="special_combo" onchange="select_special(this.value)">
<option value="0">All</option>
<%
 [
 ['Starred','starred'],
 ['Begun','begun'],
 ['with estimation','west'],
 ['without estimation','woest'],
 ['With priority','wprio'],
 ['Flat list','flat']
].each {|text,state| -%>
<option id="state<%=state%>" value="<%=state%>"<%if session[:selected_special]==state then%> selected<%end%>><%= text %></option>
<% } -%>
</select>
<br/>
<br/>
<b>Actions:</b>
<a class="btnlnk" href="/task/export_csv">CSV Export</a>
<a class="btnlnk" onclick="alert('Export by tag. The export to freemind has not been changed since the subtasking system has been introduced.');" href="/task/export_freemind">Freemind Export</a>
<%= link_to('Review', '/inbox/review', {:class=>'btnlnk' }) %>
<%=
link_to_remote('Sort by estimation',
  {:update => :taskcontent,
   :url =>{ :action => :sort_by_estimation },
   :loading=>"$('loading').show();"},
  {:class=>'btnlnk' })
%>
<a class="btnlnk" href="#" onclick="sort_by_priority(); return false;">Sort by priority</a>
<%= link_to('Estimate tasks', {:controller=>'estimations'}, {:class=>'btnlnk' }) %>
<br/>
<div style="margin:10px;">
Time available
<select id="suggest_time">
<option value="0.25">10m</option>
<option value="0.5">30m</option>
<option value="1">1h</option>
<option value="4">4h</option>
<option value="8">8h</option>
</select>
<%= link_to_function('Suggest something to do', 'suggest()', {:class=>'btnlnk' }) %><br/>
</div>


<b>Tags:</b> to add tags to a task: "urgent, work: call my boss". To filter tasks: click a tag name.<br/>
<img id="loading_tags" src="/images/icon_clock.gif" style="display:none;">
<div id="tags" style="inline">
<%= render(:partial=>'tag', :collection=>@tags, :locals=>{:project=>@project}) %>
</div>

</div> <!-- filters -->

<div id="taskcontent">
<%= render(:partial => "taskcontent", :locals=>{:by_tag=>nil}) %>
</div>

